| Country | Boundary Name | Pop-Min | Pop-Max | Household-Min | Household-Max | Total No.Scot 11’ | Total No. Glasgow 11’ |
|---|---|---|---|---|---|---|---|
| Scotland | Output Area | 50 | - | 20 | - | 46351 | 5486 |
| Datazone | 500 | 1000 | - | - | 6976 | 746 | |
| Intermediate Zone | 2500 | 6000 | - | - | 1279 | 136 | |
| England | Output Area | 100 | - | 40 | - | 181408 | - |
| Lower Super Output Area | 1000 | 3000 | 400 | 1200 | 34753 | - | |
| Middle Super Output Area | 5000 | 15000 | 2000 | 6000 | 7201 | - |
Call files: primary schools and intermediate zones
schools <-
read_sf("Glasgow/Bld_Schools_Glasgow.shp") %>%
select(DataZone, SAPE2014, Rank) %>%
mutate(FID = row_number())
iz <- read_sf("Glasgow/Glasgow_IZ.shp")
code <- read_csv("Glasgow/dz2011_codes_and_labels_21042020.csv")
## Rows: 6976 Columns: 11
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (11): DataZone, DataZoneName, IntZone, IntZoneName, CA, CAName, HSCP, HS...
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Taking a glance on the data
schools %>%
st_drop_geometry() %>%
glimpse()
## Rows: 318
## Columns: 4
## $ DataZone <chr> "S01010452", "S01010452", "S01010452", "S01010463", "S0101046~
## $ SAPE2014 <dbl> 785, 785, 785, 823, 823, 823, 670, 596, 596, 596, 596, 1008, ~
## $ Rank <dbl> 1554, 1554, 1554, 3317, 3317, 3317, 1285, 1692, 1692, 1692, 1~
## $ FID <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18~
Summary stats
schools %>%
st_drop_geometry() %>%
get_summary_stats() %>%
print(n = Inf)
## # A tibble: 3 x 13
## variable n min max median q1 q3 iqr mad mean sd se
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 FID 318 1 318 160. 80.2 239. 158. 118. 160. 91.9 5.16
## 2 Rank 318 0 6866 1057 303. 2820. 2517 1250. 1722. 1722. 96.6
## 3 SAPE2014 318 0 1200 785 644 905 261 205. 751. 267. 15.0
## # ... with 1 more variable: ci <dbl>
Rank by IZs
left_join(schools, code, by = "DataZone") %>%
select(FID, DataZone, IntZone, IntZoneName) %>%
rename(InterZone = IntZone) -> sch
sch %>%
group_by(InterZone, IntZoneName) %>%
summarise(no_of_schools = length(FID)) -> schools_area
## `summarise()` has grouped output by 'InterZone'. You can override using the
## `.groups` argument.
schools_area$no_of_schools %>% sum
## [1] 318
schools_area %>%
st_drop_geometry() %>%
arrange(desc(no_of_schools)) %>%
print(n = Inf)
## # A tibble: 101 x 3
## # Groups: InterZone [101]
## InterZone IntZoneName no_of_schools
## <chr> <chr> <int>
## 1 <NA> <NA> 20
## 2 S02001886 Cathcart 8
## 3 S02001909 Greenfield 8
## 4 S02001935 Anderston 8
## 5 S02001872 Langside 7
## 6 S02001894 Parkhead West and Barrowfield 7
## 7 S02001855 Drumoyne and Shieldhall 6
## 8 S02001915 Craigend and Ruchazie 6
## 9 S02001927 Dennistoun North 6
## 10 S02001946 Summerston North 6
## 11 S02001961 Whiteinch 6
## 12 S02001846 Crookston South 5
## 13 S02001902 Garrowhill West 5
## 14 S02001922 Springburn 5
## 15 S02001925 Sighthill 5
## 16 S02001843 Darnley North 4
## 17 S02001864 Pollokshields East 4
## 18 S02001865 Govanhill West 4
## 19 S02001873 Pollokshaws 4
## 20 S02001877 Merrylee and Millbrae 4
## 21 S02001884 Kingspark South 4
## 22 S02001889 Gorbals and Hutchesontown 4
## 23 S02001899 Mount Vernon North and Sandyhills 4
## 24 S02001901 Baillieston East 4
## 25 S02001911 Tollcross 4
## 26 S02001913 Carntyne 4
## 27 S02001917 Blackhill and Barmulloch East 4
## 28 S02001926 Roystonhill, Blochairn, and Provanmill 4
## 29 S02001928 Alexandra Parade 4
## 30 S02001951 North Kelvin 4
## 31 S02001972 Blairdardie East 4
## 32 S02001853 Penilee 3
## 33 S02001857 Craigton 3
## 34 S02001859 Ibrox 3
## 35 S02001860 Ibrox East and Cessnock 3
## 36 S02001861 Kinning Park and Festival Park 3
## 37 S02001863 Pollokshields West 3
## 38 S02001866 Govanhill East and Aikenhead 3
## 39 S02001870 Shawlands West 3
## 40 S02001876 Newlands 3
## 41 S02001883 Castlemilk 3
## 42 S02001888 Toryglen and Oatlands 3
## 43 S02001890 Laurieston and Tradeston 3
## 44 S02001898 Carmyle and Mount Vernon South 3
## 45 S02001908 Barlanark 3
## 46 S02001919 Balornock 3
## 47 S02001920 Barmulloch 3
## 48 S02001921 Petershill 3
## 49 S02001938 Woodside 3
## 50 S02001941 Ruchill 3
## 51 S02001945 Summerston Central and West 3
## 52 S02001947 Maryhill East 3
## 53 S02001948 Maryhill West 3
## 54 S02001952 Kelvingrove and University 3
## 55 S02001967 Knightswood East 3
## 56 S02001969 Knightswood Park East 3
## 57 S02001970 Anniesland East 3
## 58 S02001977 Drumry West 3
## 59 S02001845 Nitshill 2
## 60 S02001847 Crookston North 2
## 61 S02001849 Pollok North and East 2
## 62 S02001850 Cardonald South and East 2
## 63 S02001854 Hillington 2
## 64 S02001858 Mosspark 2
## 65 S02001862 Kingston West and Dumbreck 2
## 66 S02001874 Carnwadric West 2
## 67 S02001881 Glenwood South 2
## 68 S02001885 Kingspark North 2
## 69 S02001896 Braidfauld 2
## 70 S02001900 Baillieston West 2
## 71 S02001903 Garrowhill East and Swinton 2
## 72 S02001905 Central Easterhouse 2
## 73 S02001930 Dennistoun 2
## 74 S02001932 City Centre East 2
## 75 S02001934 City Centre South 2
## 76 S02001943 Milton West 2
## 77 S02001955 Partick 2
## 78 S02001959 Broomhill 2
## 79 S02001973 Blairdardie West 2
## 80 S02001975 Drumchapel North 2
## 81 S02001842 Darnley East 1
## 82 S02001852 Cardonald West and Central 1
## 83 S02001868 Strathbungo 1
## 84 S02001880 Carmunnock South 1
## 85 S02001882 Glenwood North 1
## 86 S02001887 Mount Florida 1
## 87 S02001892 Bridgeton 1
## 88 S02001893 Dalmarnock 1
## 89 S02001907 North Barlanark and Easterhouse South 1
## 90 S02001914 Cranhill, Lightburn and Queenslie South 1
## 91 S02001923 Springburn East and Cowlairs 1
## 92 S02001924 Cowlairs and Port Dundas 1
## 93 S02001933 City Centre West 1
## 94 S02001942 Possil Park 1
## 95 S02001953 Hillhead 1
## 96 S02001960 Victoria Park 1
## 97 S02001962 Scotstoun North and East 1
## 98 S02001964 Yoker South 1
## 99 S02001966 Knightswood West 1
## 100 S02001971 Anniesland West 1
## 101 S02001976 Drumry East 1
Plot
schools_area %>% st_drop_geometry() -> sch_df
iz %>%
left_join(sch_df, by = "InterZone") -> schools_choropleth
schools_choropleth %>%
ggplot() +
geom_sf(aes(fill = no_of_schools),
show.legend = NA) +
theme_bw() +
scale_fill_continuous(low="thistle2", high="darkred",
guide="colorbar",na.value="white") +
theme(legend.position = "bottom") -> schools_plotly
ggplotly(schools_plotly)